var fs = require('fs');

exports.getAllAlbums = function (callback) {
    fs.readdir('./uploads', (err, files) => {
        let allAlbums = [];
        // 迭代器
        (function interator(i) {
            if (i == files.length) {
                console.log(allAlbums);
                callback(allAlbums);
                return;
            }
            fs.stat('./uploads/' + files[i], (err, stats) => {
                if (stats.isDirectory()) {
                    allAlbums.push(files[i]);
                }
                interator(i+1);
            })
        })(0)
        
    })

}